package no.sachmuld.methodcombination.examples.annotation.designbycontract.courier;

import no.sachmuld.methodcombination.api.Condition;
import no.sachmuld.methodcombination.api.Context;
import no.sachmuld.methodcombination.api.MethodInvocation;

import java.lang.*;

/**
 *
 */
public class CourierWithBetterService extends Courier {

    public CourierWithBetterService() {

        with(new CourierBehaviour() {

            @Override
            public Condition beforeDeliver(Package pkg, Context context) {
                return new Condition("package weight < 4", pkg.getWeightInKg() < 4);
            }

            @Override
            public Delivery deliver(Package pkg, MethodInvocation<Delivery> methodInvocation) {
                return new Delivery(3);
            }

            @Override
            public Condition afterDeliver(Package pkg, Delivery delivery, Context context) {
                return new Condition("delivery time < 5", delivery.getDeliveryTimeInHours() < 5);
            }

        });
    }

}
